package com.xh.bgc.util;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class EmailTest {
	public static void sendEmail(){


		SimpleEmail email = new SimpleEmail();
		
		email.setDebug(true);
		// 设置smtp服务器
		email.setHostName("smtp.sina.com");

		// 设置授权信息
		email.setAuthentication("shy04751@sina.com", "123456080");
		email.setCharset("utf-8");

		// 设置发件人信息[发件人邮箱，发件人姓名，编码格式]
		try {
			email.setFrom("shy04751@sina.com","shy04751@sina.com", "utf-8");
			// 设置收件人信息[收件人邮箱，收件人姓名，编码格式]
			email.addTo("wuxianchen041@163.com","wuxianchen" ,"utf-8");

			// 设置主题
			email.setSubject("邮件测试");

			// 设置邮件内容
			email.setMsg("邮件测试！");

			// 发送邮件
			email.send();
		} catch (EmailException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	public static void main(String[] args) {
		EmailTest email=new EmailTest();
		email.sendEmail();
	}
}
